﻿using MrPP.UX;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
namespace MrPP.SerriedCabinet
{
    /*
    public class ShelveViewModelTemp : MonoBehaviour, IShelveModel
    {
        [SerializeField]
        private ShelveBinding _binding;


        
        public void Awake()
        {
            _binding.getPage = delegate { return page_; };
            _binding.getScanList = delegate { return this.scanList_.ToArray(); };
            _binding.getLocation = delegate { return this.location_; };
            _binding.getRunning = delegate { return running_; };
            _binding.getBinding = delegate { return map_; };
            location_.box = -1;
        }
        private BoxLocation location_;
        private List<string> scanList_ = new List<string>();

        private Dictionary<string, BoxLocation> map_ = new Dictionary<string, BoxLocation>();

        private int page_ = 0;
        private bool running_ = false;
        public void onPage(int page) {
       
            page_ = page;
            _binding.onPage?.Invoke(page);
        }
       

        public void doBinding(int id)
        {
            Debug.LogError(id);
            if (id >= 0 && id < scanList_.Count) {
                if (location_.box != -1) {
                    string sn = scanList_[id];
                    if (map_.ContainsKey(scanList_[id]))
                    {
                        map_.Remove(sn);
                    }
                    else {
                        map_[sn] = location_;
                    }
                    _binding.onBinding(map_);
                }
            }
        }

        public void doLast()
        {
            onPage(page_ - 1);
        }

        public void doNext()
        {

            onPage(page_ + 1);
        }

        public void doPlay()
        {
            running_ = true;
            this._binding.onRunning?.Invoke(running_);
        }


        public void doStop()
        {
            running_ = false;
            this._binding.onRunning?.Invoke(running_);
        }
        public void doClean() {
            scanList_.Clear();
            this._binding.onScanList?.Invoke(scanList_.ToArray());
        }
        public void doScanning(string sn)
        {
            if (scanList_.Exists(t=>(t==sn))) {
                return;
            }
            scanList_.Add(sn);
            this._binding.onScanList?.Invoke(scanList_.ToArray());
        }

        public void doSelected(BoxLocation location)
        {
            this.location_ = location;
            this._binding.onLocation(location_);
        }
    }*/
}